package de.gbeine.java.depview.ui.component;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JSeparator;

import com.google.common.eventbus.EventBus;

import de.gbeine.java.depview.event.ChangeLayoutEvent;
import de.gbeine.java.depview.event.OpenFileEvent;
import de.gbeine.java.depview.layout.CircleLayoutStrategy;
import de.gbeine.java.depview.layout.SpringLayoutStrategy;

public class FileMenu extends JMenu {

    /**
     *
     */
    private static final long serialVersionUID = 8302509911191700082L;

    private EventBus eventBus;

    public FileMenu(final EventBus pEventBus) {
        super("File");
        this.initialize();
        this.eventBus = pEventBus;
    }

    private void initialize() {
        final JMenuItem mntmOpenFile = new JMenuItem("Open File");
        mntmOpenFile.addActionListener(new ActionListener() {
            public void actionPerformed(final ActionEvent e) {
                FileMenu.this.eventBus.post(new OpenFileEvent(this));
            }
        });
        this.add(mntmOpenFile);

        final JSeparator separatorExit = new JSeparator();
        this.add(separatorExit);

        final JMenuItem mntmExit = new JMenuItem("Exit");
        mntmExit.addActionListener(new ActionListener() {
            public void actionPerformed(final ActionEvent e) {
                System.exit(0);
            }
        });
        this.add(mntmExit);
    }
}
